import java.util.Scanner;

class ListNode{
    int val;
    ListNode next = null;

    public ListNode(int val) {
        this.val = val;
    }
}

public class Partition {
    public ListNode partition(ListNode pHead, int x){
        ListNode bs = null;
        ListNode be = null;
        ListNode as = null;
        ListNode ae = null;

        ListNode cur = pHead;
        while(cur != null){
            if(cur.val < x){
                //第一次插入
                if(bs == null){
                    be = bs = cur;
                }else {
                    be.next = cur;
                    be = cur;
                }
            }else{
                //第一次插入
                if(as == null){
                    ae = as = cur;
                }else {
                    ae.next = cur;
                    ae = cur;
                }
            }
            cur = cur.next;
        }
        if(bs == null){
            return as;
        }
        be.next = as;//连接上两个链表
        if(as != null){
            ae.next = null;
        }
        return bs;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len = in.nextInt();
            int x = in.nextInt();
            ListNode dummy = new ListNode(0); // 创建虚拟头节点
            ListNode tail = dummy;
            for(int i = 0; i < len; i++){
                int val = in.nextInt(); // 读取节点值
                tail.next = new ListNode(val);
                tail = tail.next;
            }
            Partition partition = new Partition();
            ListNode result = partition.partition(dummy.next,x);
            while(result != null){
                System.out.print(result.val + " ");
                result = result.next;
            }
        }
    }
}